package com.foodplus.www.presenter;

import com.foodplus.www.api.BaseSubscriber;
import com.foodplus.www.api.ExceptionHandle;
import com.foodplus.www.bean.home.HomeBean;
import com.foodplus.www.model.impl.HomeModelImpl;
import com.foodplus.www.view.impl.HomeView;

import java.util.Map;

/**
 * Created by WangZhiChao on 2016/10/31.
 */

public class HomePresenter {
    HomeView homeView;

    public HomePresenter(HomeView homeView) {
        this.homeView = homeView;
    }

    public void getHomeData( Map<String, String> params) {
        new HomeModelImpl().getHomeData(new BaseSubscriber<HomeBean>() {

            @Override
            public void onSuccess(HomeBean homeBean) {
                homeView.onSuccess(homeBean);
            }

            @Override
            public void onFail(ExceptionHandle.ResponeThrowable e) {
                homeView.onFail(e);
            }

            @Override
            public void onFinished() {
                homeView.onFinish();
            }
        }, params);
    }
}
